package com.cms.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.action.DefaultAction;
import com.cms.model.Language;
import com.cms.model.Tactics;
import com.cms.model.Type;
import com.cms.service.LanguageService;
import com.cms.service.LanguageServiceImpl;
import com.cms.service.TacticsService;
import com.cms.service.TacticsServiceImpl;
import com.cms.service.TypeService;
import com.cms.service.TypeServiceImpl;

public class TacticsAction extends DefaultAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private TacticsService service;
	private Tactics model;
	private List<Tactics> list;
	private List<Language> llist;
	private List<Type> tlist;
	private LanguageService lservice;
	private TypeService tservice;
	private String actype;
	private String ssave="";
	private String msg = "";
	
	public TacticsAction()
	{
		service = new TacticsServiceImpl();
		lservice = new LanguageServiceImpl();
		tservice = new TypeServiceImpl();
	}
	public String list()
	{
		list = service.getTacticss();
		llist = lservice.getAll();
		tlist = tservice.getAll();
		return SUCCESS;
	}
	public String show()
	{
		if(ssave.equals("save"))
		{
			String fmt = "yyyy-MM-dd HH:mm:ss";
			SimpleDateFormat sdf = new SimpleDateFormat(fmt);
			model.setCreatetime(sdf.format(new Date()));
			model.setCreateuser(getAdminLoginName());
			service.saveTactics(model, actype);
			msg = "保存成功！";
		}
		llist = lservice.getAll();
		tlist = tservice.getAll();
		if(actype.equals("update"))
		{
			model = service.getTacticss(model.getId());
		}
		return SUCCESS;
	}
	public String save()
	{
		String fmt = "yyyy-MM-dd HH:mm:ss";
		SimpleDateFormat sdf = new SimpleDateFormat(fmt);
		model.setCreatetime(sdf.format(new Date()));
		model.setCreateuser(getAdminLoginName());
		service.saveTactics(model, actype);
		return SUCCESS;
	}
	/**
	 * @return the model
	 */
	public Tactics getModel() {
		return model;
	}
	/**
	 * @param model the model to set
	 */
	public void setModel(Tactics model) {
		this.model = model;
	}
	/**
	 * @return the list
	 */
	public List<Tactics> getList() {
		return list;
	}
	/**
	 * @param list the list to set
	 */
	public void setList(List<Tactics> list) {
		this.list = list;
	}
	/**
	 * @return the llist
	 */
	public List<Language> getLlist() {
		return llist;
	}
	/**
	 * @param llist the llist to set
	 */
	public void setLlist(List<Language> llist) {
		this.llist = llist;
	}
	/**
	 * @return the tlist
	 */
	public List<Type> getTlist() {
		return tlist;
	}
	/**
	 * @param tlist the tlist to set
	 */
	public void setTlist(List<Type> tlist) {
		this.tlist = tlist;
	}
	public String getActype() {
		return actype;
	}
	public void setActype(String actype) {
		this.actype = actype;
	}
	public String getSsave() {
		return ssave;
	}
	public void setSsave(String ssave) {
		this.ssave = ssave;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	
	
}
